#include<bits/stdc++.h>
using namespace std;
const int MAXN=5e4+10;
int n,buc[MAXN],a[MAXN],m1[MAXN],cnt,ans[MAXN];
int main()
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		memset(buc,0,sizeof(buc));
		map<int,int>m2;
		scanf("%d",&n);
		for(int i=1;i<=n;++i)scanf("%d",&a[i]);
		memcpy(m1,a,sizeof(a));
		sort(m1+1,m1+1+n);
		cnt=unique(m1+1,m1+1+n)-m1-1;
		for(int i=1;i<=cnt;++i)m2[m1[i]]=i;
		cnt=0;
		for(int i=1;i<=n;++i)
		{
			if(!buc[m2[a[i]]])
			{
				ans[++cnt]=a[i];
				buc[m2[a[i]]]=true;
			}
		}
		for(int i=1;i<=cnt;++i)
		{
			printf("%d",ans[i]);
			if(i!=cnt)printf(" ");
		}
		printf("\n");
	}
	return 0;
}
